package com.appkubes.mall.admin.application.customer.collect.dao;

import com.appkubes.mall.admin.application.customer.collect.entity.dto.GoodsCollectDTO;
import com.appkubes.mall.core.dao.BaseMallCustomerCollectDao;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: Lin Jiaming
 * @Date: 2020/3/4 16:08
 * @Description:
 */
public interface CustomerCollectDao extends BaseMallCustomerCollectDao {
    @Select("<script>" +
            "SELECT t1.collect_key,t1.collect_type,t1.create_time,t2.goods_key,t2.goods_id,t2.main_pic,t2.title," +
            "t2.shop_type,t2.actual_price,t2.commission_rate,t2.month_sales,t2.coupon_price " +
            "FROM mall_customer_collect AS t1 " +
            "INNER JOIN mall_goods_taobao AS t2 " +
            "ON t1.target_key=t2.goods_key " +
            "WHERE t1.collect_type='GOODS' " +
            "AND t1.customer_key='${customerKey}' " +
            "<when test='sort==1'>" +
            "ORDER BY t1.create_time DESC " +
            "</when>" +
            "<when test='sort==2'>" +
            "ORDER BY t1.create_time ASC " +
            "</when>" +
            "<when test='sort==3'>" +
            "ORDER BY t2.month_sales DESC " +
            "</when>" +
            "<when test='sort==4'>" +
            "ORDER BY t2.month_sales ASC " +
            "</when>" +
            "</script>")
    List<GoodsCollectDTO> goodsCollectList(@Param("customerKey") String customerKey, @Param("sort") Integer sort, Page pageInfo);
}
